function submit_form() {
    show("00");
    if(isEmpty($("#name").val())){
        alert("请输入你要执行的命令");
        return false
    }
    var data = {
        'name': $("#name").val()
    };
    if(!confirm("确定执行命令：" + data['name'] + " ?")){
        return false
    }

    $.ajax({
        type:'POST',
        //url: '{{url_for("main.execute")}}',
        url: '/main/execute',
        data: data,
        dataType: 'json',
        success: function (data) {
            var newdata = data.result;

            var divStr = $("#div_00");
            divStr.empty();
            var apanStr = [];

            for (var j = 0; j < newdata.length; j++){
                var result = newdata[j].split("\n");
                for (var i in result) {
                    apanStr[i] = $("<p>" + result[i] + "</p>");
                    divStr.append(apanStr[i]);
                }
            }
            hide()
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("系统异常 - " + jqXHR.status + " - " + errorThrown +  "\n" + jqXHR.responseText);
            hide()
        }
    });
}

function isEmpty(info) {
    if (trim(info) == null || info == undefined || trim(info).length == 0){
        return true;
    }
    return false
}

// 删除左右两端的空格
function trim(str){
    return str.replace(/(^\s*)|(\s*$)/g, "");
}

function commands(methodName, seq) {
    show(seq);
    $.ajax({
        type:'POST',
        url: '/main/' + methodName,
        dataType: 'json',
        success: function (data) {
            var newdata = data.result;
            // alert(newdata);
            /*var table = $("#ListTable_" + seq);
            var body = table.find('tbody:eq(0)');
            body.empty();
            var tr;*/

            var divStr = $("#div_" + seq);
            divStr.empty();
            var apanStr = new Array();

            for (var j = 0; j < newdata.length; j++){
                var result = newdata[j].split("\n");
                for (var i in result) {
                    /*tr = $("<tr class=\"success\" id='table_" + i + "' ></tr>");
                    tr.append($("<td>" + result[i] + "</td>"));
                    table.append(tr);*/

                    apanStr[i] = $("<p>" + result[i] + "</p>");
                    divStr.append(apanStr[i]);
                }
            }
            hide();
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("系统异常 - " + jqXHR.status + " - " + errorThrown +  "\n" + jqXHR.responseText);
            hide();
        }
    });
}